package com.woniuxy.service.Impl;

import com.ruoyi.common.core.domain.AjaxResult;
import com.woniuxy.dao.FinaFowDao;
import com.woniuxy.entity.BeforeQueryData;
import com.woniuxy.entity.FinaAccount;
import com.woniuxy.entity.FinaFow;
import com.woniuxy.service.FinaFowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 银行流水及现金录入录入接口实现类
 */
@Service
public class FinaFowServiceImpl implements FinaFowService {

    @Autowired
    private
    FinaFowDao finaFowDao;

    @Override
    public List<FinaFow> initFinaFowPage() {
        List<FinaFow> all = finaFowDao.initFinaFowPage();
        return all;
    }


    @Override
    public AjaxResult addFinaFow(FinaFow finaFow) {
      int accountId=  finaFowDao.getById(finaFow.getFinaAccount().getBankCard());
        finaFow.setAccountId(accountId);
        finaFowDao.addFinaFow(finaFow);
        return AjaxResult.success("录入成功");
    }

    @Override
    public AjaxResult updateFinaFow(FinaFow finaFow) {
        finaFowDao.updateFinaFow(finaFow);

        return AjaxResult.success("修改成功");
    }

    @Override
    public List<FinaFow> listCashFlow() {
        List<FinaFow> all = finaFowDao.listCashFlow();
        return all;
    }

    @Override
    public AjaxResult addCashFlow(FinaFow finaFow) {
        finaFowDao.addCashFlow(finaFow);
        return AjaxResult.success("录入成功");
    }

    @Override
    public AjaxResult updateCashFlow(FinaFow finaFow) {
        finaFowDao.updateCashFlow(finaFow);
        return AjaxResult.success("修改成功");
    }

    @Override
    public List<FinaFow> queryBankFlow(BeforeQueryData beforeQueryData) {

        List<FinaFow> all = finaFowDao.queryBankFlow(beforeQueryData);
        return all;
    }

    @Override
    public List<FinaFow> queryCashFlow(BeforeQueryData beforeQueryData) {
        List<FinaFow> all = finaFowDao.queryCashFlow(beforeQueryData);
        return all;
    }
}
